package com.bprogram.Enum;

public enum UserRole {
    
    SUPER("super","超级管理员"),
    ROOT("root","管理员"),
    VIP("vip","VIP用户"),
    NORMAL("normal","普通用户");
    private String key;
    private String value;

    UserRole() {
    }

    public String getKey() {
        return key;
    }

    public void setKey(String key) {
        this.key = key;
    }

    public String getValue() {
        return value;
    }

    public void setValue(String value) {
        this.value = value;
    }
    UserRole(String key, String value) {
        this.key = key;
        this.value = value;
    }
    /**
     * 通过key获取value
     * @param key
     * @return
     */
    public static String getValue(String key){
        UserRole[] UserRoles = values();
        for (UserRole role :UserRoles){
            if (role.getKey().equals(key)){
                return role.getValue();
            }
        }
        return null;
    }

    /**
     * 通过value获取key
     * @param value
     * @return
     */
    public static String getKey(String value){
        UserRole[] UserRoles = values();
        for (UserRole role :UserRoles){
            if (role.getValue().equals(value)){
                return role.getKey();
            }
        }
        return null;
    }


}
